<%--
  Created by IntelliJ IDEA.
  User: Yang
  Date: 2021/11/22
  Time: 13:38
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>

<!DOCTYPE html>
<html>
<%@include file="common/head.jsp"%>
<body style="background-color:white" class="nav-md">
<div class="container body">
    <div style="padding-right: 15px;
    padding-left: 259px;
    margin-right: auto;
    margin-left: auto;">
        <div class="row">
            <p><span style="font-size: 20px">手游&nbsp;审核列表<span class="glyphicon glyphicon-user"></span></span> 系统管理员-您可以通过搜索或者其他的筛选项对手游的信息进行审核操作</p>
        </div>
        <form action="${pageContext.request.contextPath}/backappInfo/appInfoList" method="post">
            <input type="hidden" value="1"  name="pageNum">
            <div class="row">
                <div class="col-md-4 form-group">
                    <label class="col-sm-2 control-label">手游名称</label>
                    <input type="text" name="softwareName"   placeholder="输入手游名称" value="${softwareName}">

                </div>
                <div class="col-md-4 col-sm-12 col-xs-12 form-group">
                    <label class="col-sm-2 control-label">所属平台</label>
                    <div class="col-sm-9">
                        <select class="form-control" id="flatformId" name="flatformId">
                            <option value="0">请选择</option>
                        <c:forEach items="${ddry}" var="dd">
                            <c:if test="${flatformId==dd.valueId}">
                                <option value="${dd.valueId}" selected="selected">${dd.valueName}</option>
                            </c:if>
                            <c:if test="${flatformId!=dd.valueId}">
                                <option value="${dd.valueId}">${dd.valueName}</option>
                            </c:if>
                        </c:forEach>
                        </select>
                    </div>
                </div>
                <div class="col-md-4 col-sm-12 col-xs-12 form-group">
                    <label class="col-sm-2 control-label">一级分类</label>
                    <input type="hidden" id="level1" value="${categoryLevel1}"/>
                    <div class="col-sm-9">
                        <select class="form-control" name="categoryLevel1" id="categoryLevel1">
                        </select>
                    </div>
                </div>
                <div class="col-md-4 col-sm-12 col-xs-12 form-group">
                    <label class="col-sm-2 control-label">二级分类</label>
                    <input type="hidden" id="level2" value="${categoryLevel2}"/>
                    <div class="col-sm-8">
                        <select class="form-control" name="categoryLevel2"  id="categoryLevel2">
                        </select>
                    </div>
                </div>
                <div class="col-md-4 col-sm-12 col-xs-12 form-group">
                    <label class="col-sm-2 control-label">三级分类</label>
                    <input type="hidden" id="level3" value="${categoryLevel3}"/>
                    <div class="col-sm-9">
                        <select class="form-control" name="categoryLevel3" id="categoryLevel3">
                        </select>
                    </div>
                </div>
                <div class="col-xs-6 col-sm-4">
                    <button type="submit" class="btn btn-primary btn-sm" id="sub">查询</button>
                </div>
            </div>
        </form>
        <div class="row">
            <table class="table table-bordered">
                <tr>
                    <td>手游名称</td>
                    <td>APK名称</td>
                    <td>所属平台</td>
                    <td>所属分类(一级分类、二级分类、三级分类)</td>
                    <td>状态</td>
                    <td>软件大小(单位:M)</td>
                    <td>下载次数</td>
                    <td>最新版本号</td>
                    <td>操作</td>
                </tr>
                <c:forEach items="${appInfo}" var="app">
                    <tr>
                        <td>${app.softwareName}</td>
                        <td>${app.APKName}</td>
                        <td>${app.flatformname}</td>
                        <td>${app.categoryLevel1Name}>${app.categoryLevel2Name}>${app.categoryLevel3Name}</td>
                        <td>${app.statusname}</td>
                        <td>${app.softwareSize}</td>
                        <td>${app.downloads}</td>
                        <td>${app.versionname}</td>
                        <c:if test="${app.versionname!=null}">
                            <td><a href="${pageContext.request.contextPath}/backappInfo/auditView/${app.id}/${app.versionId}" type="button" class="btn btn-primary btn-sm">审核</a></td>
                        </c:if>
                        <c:if test="${app.versionname==null}">
                            <td><a href="javascript:;" type="button" class="btn btn-primary btn-sm">审核</a></td>
                        </c:if>
                    </tr>
                </c:forEach>
            </table>
            <div class="row" style="margin-right: auto">
                <span> 共${totalCount}记录&nbsp;${pageIndex}/${total}</span>



                        <ul class="pager">
                            <c:if test="${pageIndex>1}">
                            <li><a href="${pageContext.request.contextPath}/backappInfo/appInfoList?pageNum=1" >首页</a></li>
                            <li><a href="${pageContext.request.contextPath}/backappInfo/appInfoList?pageNum=${pageIndex-1}" >上一页</a></li>
                            </c:if>
                            <c:if test="${pageIndex<total}">
                                <li> <a href="${pageContext.request.contextPath}/backappInfo/appInfoList?pageNum=${pageIndex+1}" >下一页</a></li>
                                <li> <a href="${pageContext.request.contextPath}/backappInfo/appInfoList?pageNum=${total}" >最后一页</a></li>
                            </c:if>
                        </ul>

            </div>
        </div>

    </div>
</div>
</body>
<%@include file="common/foot.jsp"%>
<script src="${pageContext.request.contextPath}/statics/js/jquery-1.12.4.js"></script>
<script>

    var option=null
    var path='${pageContext.request.contextPath}';
    $(function () {

        $.getJSON(path+"/category/fenlei1",'',function (data){
            option="<option value='0'>请选择</option>";
            for (var i = 0; i < data.length; i++) {
                option+="<option value='"+data[i].id+"'>"+data[i].categoryName+"</option>"
            }
            $("#categoryLevel1").html(option);
        })
        $.getJSON(path+"/category/fenlei1",'',function (data){
            option="<option value='0'>请选择</option>";
            for (var i = 0; i < data.length; i++) {
                if($("#level1").val()==data[i].id){
                    option+="<option selected='selected' value='"+data[i].id+"'>"+data[i].categoryName+"</option>"
                }else{
                    option+="<option value='"+data[i].id+"'>"+data[i].categoryName+"</option>"
                }
            }
            $("#categoryLevel1").html(option);
        })
        $.ajax({
            type: "GET",
            url:path+"/category/fenlei2",
            data:{parentId:$("#level1").val()},
            dataType:"json",
            success:function (data){
                option="<option value='0'>请选择</option>";
                for (var i = 0; i < data.length; i++) {
                    if($("#level2").val()==data[i].id){
                        option+="<option selected='selected' value='"+data[i].id+"'>"+data[i].categoryName+"</option>"
                    }else{
                        option+="<option value='"+data[i].id+"'>"+data[i].categoryName+"</option>"
                    }
                }
                $("#categoryLevel2").html(option);
            }
        })
        $.ajax({
            type: "GET",
            url:path+"/category/fenlei3",
            data:{parentId:$("#level2").val()},
            dataType:"json",
            success:function (data){
                option="<option value='0'>请选择</option>";
                for (var i = 0; i < data.length; i++) {
                    if($("#level3").val()==data[i].id){
                        option+="<option selected='selected' value='"+data[i].id+"'>"+data[i].categoryName+"</option>"
                    }else{
                        option+="<option value='"+data[i].id+"'>"+data[i].categoryName+"</option>"
                    }
                }
                $("#categoryLevel3").html(option);
            }
        })
        $("#categoryLevel1").change(function (){
            var categoryLevel1=$("#categoryLevel1").val();
            if(categoryLevel1!="" && categoryLevel1!=null){

                $.ajax({
                    type: "GET",
                    url:path+"/category/fenlei2",
                    data:{parentId:categoryLevel1},
                    dataType:"json",
                    success:function (data){
                        option="<option value='0'>请选择</option>";
                        for (var i = 0; i < data.length; i++) {
                            option+="<option value='"+data[i].id+"'>"+data[i].categoryName+"</option>"
                        }
                        $("#categoryLevel2").html(option);
                    },
                    error:function (data){
                        alert("加载二级菜单失败")
                    }
                })
            }else{
                $("#categoryLevel2").html("");
                option="<option value='0'>请选择</option>";
                $("#categoryLevel2").html(option);
            }
            $("#categoryLevel3").html("");
            option="<option value='0'>请选择</option>";
            $("#categoryLevel3").html(option);
        })
        $("#categoryLevel2").change(function (){
            var categoryLevel2=$("#categoryLevel2").val();
            if(categoryLevel2!="" && categoryLevel2!=null) {
                $.ajax({
                    type: "GET",
                    url: path+"/category/fenlei3",
                    data: {parentId: categoryLevel2},
                    dataType: "json",
                    success: function (data) {
                        option = "<option value='0'>请选择</option>";
                        for (var i = 0; i < data.length; i++) {
                            option += "<option value='" + data[i].id + "'>" + data[i].categoryName + "</option>"
                        }
                        $("#categoryLevel3").html(option);
                    },
                    error:function (data){
                        alert("加载三级菜单失败")
                    }
                })
            }
        })
    })
</script>
</html>
